home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / NCSA / tn3270 2.4d7 source / NCSA⁄BYU TCP⁄IP / fastnet.c < prev    next >
Text File  |  1991-06-27  |  3KB  |  142 lines

  1. #ifndef lint
  2. static char *SCCSid = "%W%    (NCSA)    %G%";
  3. #endif
  4. /*
  5. *    fastnet.c
  6. *     by Gaige B. Paulsen
  7. ****************************************************************************
  8. *                                                                          *
  9. *      Uses    :                                                               *
  10. *      TCP/IP kernel for NCSA Telnet                                       *
  11. *      by Tim Krauskopf                                                    *
  12. *       with Macintosh code by Gaige B. Paulsen                                 *
  13. *                                                                          *
  14. *      National Center for Supercomputing Applications                     *
  15. *      152 Computing Applications Building                                 *
  16. *      605 E. Springfield Ave.                                             *
  17. *      Champaign, IL  61820                                                *
  18. *                                                                          *
  19. *                                                                          *
  20. ****************************************************************************
  21. *
  22. *    FastNet init and shutdown (and utility) procs.    
  23. *
  24. *    Called by:
  25. *        ether.c
  26. *        mactools.c
  27. *        macutil.c
  28. */
  29. #include <stdio.h>
  30.  
  31. #include "protocol.h"
  32. #include "data.h"
  33.  
  34. #include "BoxLayer.h"
  35. #include "datalayer.h"
  36. #include "dlayer.h"
  37. #include "ip.h"
  38.  
  39. extern char nodeAddress[];
  40.  
  41. int FNdlayersend            /*MAC: replaced */
  42.   (
  43.     DLAYER *ptr,
  44.     unsigned size
  45.   )
  46. {
  47.     if (size<60) size=60;
  48.     DoBoxDataSend( ptr, size);
  49.     return(0);
  50. }
  51.  
  52. /**********************************************************************/
  53. /*   FNdemux    - FastNet Version of DEMUX routine
  54. *
  55. *  returns the number of packets demuxed
  56. */
  57. int FNdemux
  58.   (
  59.     int all
  60.   )
  61. {
  62.     unsigned getcode;
  63.     int nmuxed;
  64.     typedef struct peek {
  65.         unsigned char dest[DADDLEN],
  66.             me[DADDLEN];
  67.         unsigned type;
  68.     } Dpeek;
  69.  
  70.     Dpeek *firstlook;
  71.  
  72.     nmuxed = 0;
  73.  
  74.     do {                                    /* while all flag is on */
  75.         if (DoBoxDataRequest(bufinfo.buforg))    { /*MAC*/
  76.             nmuxed++;
  77.             firstlook = (Dpeek *) bufinfo.buforg;     /*MAC where packet is */
  78.  
  79.             getcode = firstlook->type;            /* where does it belong? */
  80.  
  81.             switch (getcode) {                    /* what to do with it? */
  82.                 case EARP:
  83.                 case ERARP:
  84.                     arpinterpret((ARPKT *) firstlook->dest); /* handle [R]ARP packet */
  85.                     break;
  86.                 case EIP:
  87.                     ipinterpret((IPKT *) firstlook->dest);    /* handle IP packet */
  88.                     break;
  89.                 default:
  90.                     break;
  91.             }
  92.         }
  93.         else 
  94.             all = 0;
  95.     } while (all);            /* should we look for more to deal with? */
  96.  
  97.     return(nmuxed);          /* no packets anymore */
  98.  
  99. }
  100.  
  101. void getFNaddress
  102.   (
  103.     char *p
  104.   )
  105. {
  106.     DoBoxAddrRequest( p);
  107. }
  108.  
  109. int FNopen
  110.   (
  111.     void
  112.   )
  113. {
  114.     DataLinkData lanceData;
  115.  
  116.     getFNaddress(&lanceData.physicalAddress[0]);
  117.  
  118.     /* Initialize address globals (DEC and EtherNet forms) */
  119.     lanceData.promiscuousEnable=0;
  120.     /* movmem(nodeAddress, &lanceData.physicalAddress[0],6); */
  121.     lanceData.protocolCount=3;
  122.     lanceData.protocolType[0]=0x0800;        /*IP  */
  123.     lanceData.protocolType[1]=0x0806;        /*ARP */
  124.     lanceData.protocolType[2]=0x8035;        /*RARP*/
  125.     lanceData.multicastCount=0;
  126.     lanceData.broadcastEnable=1;
  127.  
  128.     DoBoxCommand(&lanceData,sizeof(DataLinkData));
  129.  
  130.     getFNaddress( nnmyaddr);
  131.     return(0);
  132. }
  133.  
  134. int FNclose
  135.   (
  136.     void
  137.   )
  138.   {
  139.     return
  140.         0;
  141.   }
  142.